< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/guide/sample_code.xhp

(bookmark: bm_id3155338)
programming examples for controls
dialogs;loading (example)
dialogs;displaying (example)
controls;reading or editing properties (example)
list boxes;removing entries from (example)
list boxes;adding entries to (example)
examples; programming controls
dialog editor;programming examples for controls

コントロール制御のプログラミング例
ダイヤログ;読み込み (例)
ダイヤログ;表示 (例)
コントロール;読み込み、編集の属性 (例)
リストボックス; 入力項目の削除(例)
リストボックス;入力項目の追加 (例)
プログラミング例; コントロール制御

(variable: sample_code)Programming Examples for Controls in the Dialog Editor
(variable: sample_code)ダイアログエディタでのコントロール制御用プログラミングの例(hd_id3155338.1)

The following examples are for a new dialog called "Dialog1". Use the tools on the Toolbox bar in the dialog editor to create the dialog and add the following controls: a Check Box called "CheckBox1", a Label Field called "Label1", a Button called "CommandButton1", and a List Box called "ListBox1".
下記の例は、「Dialog1」と名付けた新規ダイアログを制御するためのものです。 このダイアログを作成する際には、ダイアログエディタ上で コントロール 可動ツールバーを表示させ、該当するツールを用いて、次のコントロールを配置しておきます: 「CheckBox1」という名前の チェックボックス 1 個、「Label1」という名前の ラベルフィールド (図表番号ボックス) 1 個、「CommandButton1」という名前の ボタン 1 個、「ListBox1」という名前の リストボックス 1 個。(par_id3153031.2)

Warning Icon 警告マーク Be consistent with uppercase and lowercase letter when you attach a control to an object variable.
オブジェクト変数にコントロールを割り当てる際には、上記の名前の大文字と小文字を一致させる必要があります。(par_id3154141.3)

Global Function for Loading Dialogs
ダイアログの読み込み用の大域関数(hd_id3154909.4)

Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)(par_id3153193.73)

Dim oLib as Object
Dim oLib as Object(par_id3145787.74)

Dim oLibDialog as Object
Dim oLibDialog as Object(par_id3148576.75)

Dim oRuntimeDialog as Object
Dim oRuntimeDialog as Object(par_id3153726.76)

If IsMissing(oLibContainer ) then
If IsMissing(oLibContainer ) then(par_id3149261.77)

oLibContainer = DialogLibraries
oLibContainer = DialogLibraries(par_id3148646.78)

End If
End If(par_id3151115.79)

oLibContainer.LoadLibrary(LibName)
oLibContainer.LoadLibrary(LibName)(par_id3146986.80)

oLib = oLibContainer.GetByName(Libname)
oLib = oLibContainer.GetByName(Libname)(par_id3145366.81)

oLibDialog = oLib.GetByName(DialogName)
oLibDialog = oLib.GetByName(DialogName)(par_id3145271.82)

oRuntimeDialog = CreateUnoDialog(oLibDialog)
oRuntimeDialog = CreateUnoDialog(oLibDialog)(par_id3144764.83)

LoadDialog() = oRuntimeDialog
LoadDialog() = oRuntimeDialog(par_id3153876.84)

End Function
End Function(par_id3156286.85)

Displaying a Dialog
ダイアログの表示(hd_id3149412.18)

rem global definition of variables
rem 変数の大域定義(par_id3145801.86)

Dim oDialog1 AS Object
Dim oDialog1 AS Object(par_id3150716.87)

Sub StartDialog1
Sub StartDialog1(par_id3154510.88)

BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")(par_id3146913.162)

oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")(par_id3150327.89)

oDialog1.Execute()
oDialog1.Execute()(par_id3155767.92)

end sub
end sub(par_id3149019.93)

Read or Edit Properties of Controls in the Program
プログラム中でのコントロールのプロパティーの取得と変更(hd_id3150042.27)

Sub Sample1
Sub Sample1(par_id3159267.136)

BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")(par_id3155335.163)

oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")(par_id3163808.137)

REM get dialog model
REM ダイアログモデルの取得(par_id3145232.138)

oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model(par_id3146316.139)

REM display text of Label1
REM Label1 のテキストの表示(par_id3154021.140)

oLabel1 = oDialog1.GetControl("Label1")
oLabel1 = oDialog1.GetControl("Label1")(par_id3150301.141)

MsgBox oLabel1.Text
MsgBox oLabel1.Text(par_id3152584.142)

REM set new text for control Label1
REM Label1 のテキストの変更(par_id3151277.143)

oLabel1.Text = "New Files"
oLabel1.Text = "New Files"(par_id3154119.144)

REM display model properties for the control CheckBox1
REM CheckBox1 コントロールのモデルプロパティーの表示(par_id3155115.145)

oCheckBox1Model = oDialog1Model.CheckBox1
oCheckBox1Model = oDialog1Model.CheckBox1(par_id3166426.146)

MsgBox oCheckBox1Model.Dbg_Properties
MsgBox oCheckBox1Model.Dbg_Properties(par_id3153270.147)

REM set new state for CheckBox1 for model of control
REM コントロールモデルでの CheckBox1 の状態の変更(par_id3149817.148)

oCheckBox1Model.State = 1
oCheckBox1Model.State = 1(par_id3145134.149)

REM display model properties for control CommandButton1
REM CommandButton1 コントロールのモデルプロパティーの表示(par_id3159102.150)

oCMD1Model = oDialog1Model.CommandButton1
oCMD1Model = oDialog1Model.CommandButton1(par_id3152777.151)

MsgBox oCMD1Model.Dbg_Properties
MsgBox oCMD1Model.Dbg_Properties(par_id3149209.152)

REM display properties of control CommandButton1
REM CommandButton1 コントロールの表示(par_id3150368.153)

oCMD1 = oDialog1.GetControl("CommandButton1")
oCMD1 = oDialog1.GetControl("CommandButton1")(par_id3150883.154)

MsgBox oCMD1.Dbg_Properties
MsgBox oCMD1.Dbg_Properties(par_id3155380.155)

REM execute dialog
REM ダイアログの実行(par_id3150201.156)

oDialog1.Execute()
oDialog1.Execute()(par_id3154485.157)

End Sub
End Sub(par_id3146115.158)

Add an Entry to a ListBox
リストボックスへの項目追加(hd_id3145387.55)

Sub AddEntry
Sub AddEntry(par_id3155088.122)

BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")(par_id3154528.164)

oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")(par_id3159222.159)

REM adds a new entry to the ListBox
REM リストボックスへの項目追加(par_id3148700.123)

oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model(par_id3159173.124)

oListBox = oDialog1.GetControl("ListBox1")
oListBox = oDialog1.GetControl("ListBox1")(par_id3153305.125)

dim iCount as integer
dim iCount as integer(par_id3153914.126)

iCount = oListbox.ItemCount
iCount = oListbox.ItemCount(par_id3151243.127)

oListbox.additem("New Item" & iCount,0)
oListbox.additem("New Item" & iCount,0)(par_id3144504.128)

end sub
end sub(par_id3149328.129)

Remove an Entry from a ListBox
リストボックスからの項目の削除(hd_id3147071.64)

Sub RemoveEntry
Sub RemoveEntry(par_id3159095.130)

BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")(par_id3154958.165)

oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")(par_id3149443.160)

REM remove the first entry from the ListBox
REM リストボックスの 1 番目の項目の削除(par_id3153247.131)

oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model(par_id3151302.132)

oListBox = oDialog1.GetControl("ListBox1")
oListBox = oDialog1.GetControl("ListBox1")(par_id3153976.133)

oListbox.removeitems(0,1)
oListbox.removeitems(0,1)(par_id3155383.134)

end sub
end sub(par_id3150892.135)

(embed text/sbasic/guide/create_dialog.xhp#create_dialog : linkinfo)

Creating a Basic Dialog
Basic ダイアログの作成(hd_id3149346.1)

(/embed text/sbasic/guide/create_dialog.xhp#create_dialog)


< Prev / Next >